import * as utilsApi from '~/apis/utils/utilsApi';

// 获取图片静态资源
export const getPhotoBlob = async (id: number | string) => {
  const result = await utilsApi.getFile({ id });

  if (result.code !== 200) {
    return null;
  }

  return URL.createObjectURL(result.data);
};

// 获取文件名及其后缀（以 '.' 分隔） [fullName, fileName, extensionName]
export const splitFileName = (filename: string) => {
  const regex = /^([^\\]*)\.(\w+)$/;
  const matches = regex.exec(filename);

  return matches;
};
